function fenceTabCtrl($scope, $http){
  'ngInject';

  // 获取统计信息
  this.getFenceTabInfo = () => {
  	this.personSum = 0;
  	let tenderId = '5BED013543A245028CFFC00A19B02133';
  	$http
  		.get(`${SERVER_CONTEXT}/api/electronFence/getFenceListByTenderId/` + tenderId)
  		.success((resp) => {
  			console.log(resp);
  			if (resp.success) {
  				$scope.fenceAreaData = resp.data;
  			}
  		})
  }

  $scope.toggleFenceTab = (fenceAreaDataItem, fenceAreaData) => {
  	fenceAreaData.forEach((item) => {
  		if (fenceAreaDataItem == item) {
  			item.active = !!!item.active;
  			$scope.shouldShowAreaList = item.type == 3 ? false : item.active;
  			if (item.active) {
  				$scope.activeAreaData = item.fenceDataList;

  				if (item.type == 3) {
  					$scope.getWorkerInfo(item);
  				}
  			}
  			$scope.isFenceTabActive = item.active;
  		} else {
  			item.active = false;
  		}
  	});
  }

  $scope.activeFenceAreaBtn = (areaItemId, activeAreaData) => {
  	activeAreaData.forEach((item) => {
  		if (item.id == areaItemId) {
  			if (!!!item.active) {
  				item.active = true;
  			}
  		} else {
  			item.active = false;
  		}
  	});
 		$scope.$apply();
  }

  $scope.getWorkerInfo = (item) => {
  	$http
  		.post(`${SERVER_CONTEXT}/api/electronFence/getWorkerListByFenceCondition/`,
  			{id: item.id, type: item.type})
  		.success((resp) => {
  			console.log(resp);
  			if (resp.success) {
  				$scope.queryWorkerInfo = resp.data;
  			}
  		})
  }

  this.initPage = () => {
  	this.getFenceTabInfo();

  	$scope.shouldShowAreaList = false;
  	$scope.$watchCollection('activeAreaData', function(newVal, oldVal, $scope) {
  		if (!newVal || !newVal.length) return;
  		newVal.forEach((item) => {
  			if (item.active) {
  				$scope.getWorkerInfo(item);
  			}
  		});
  	});

  	$scope.lang = [{a: 3}, 'Java', 'C#', 'Python'];
  	$scope.$watchCollection('lang', function (newVal, oldVal) {
  	    console.log("new:"+newVal,"old:"+oldVal)
  	});
  	$scope.lang = [{a: 4}, 'Java', 'C#', 'Python'];
  }

  this.initPage();
}

export default fenceTabCtrl;